﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

using PickGold.Handler;
using PickGold.Generic;

namespace PickGold.Arguments
{
	/// <summary>
	/// 包含事件数据的类
	/// </summary>
	/// <typeparam name="TYPE">事件数据的类型</typeparam>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE> : EventArgs, ICommon<TYPE>
	{
		/// <summary>
		/// 构造参数类型的一个实例
		/// </summary>
		public EventArgs()
		{
		}

		/// <summary>
		/// 构造参数类型的一个实例
		/// </summary>
		/// <param name="value">事件数据</param>
		public EventArgs(TYPE value)
		{
			this.Value = value;
		}

		/// <summary>
		/// 事件数据
		/// </summary>
		public TYPE Value;

		/// <summary>
		/// 附加的数据
		/// </summary>
		public object Tag;

		TYPE ICommon<TYPE>.Value
		{
			get
			{
				return this.Value;
			}
			set
			{
				this.Value = value;
			}
		}

		HByReturnDelegate<TYPE, TYPE> ICommon<TYPE>.Handler
		{
			get
			{
				return p => this.Value;
			}
			set
			{
				if (value != null)
					this.Value = value(this.Value);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1> : EventArgs<TYPE>, ICommon<T1>
	{
		/// <summary/>
		public T1 Value1;

		T1 ICommon<T1>.Value
		{
			get
			{
				return this.Value1;
			}
			set
			{
				this.Value1 = value;
			}
		}

		HByReturnDelegate<T1, T1> ICommon<T1>.Handler
		{
			get
			{
				return p => this.Value1;
			}
			set
			{
				if (value != null)
					this.Value1 = value(this.Value1);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2> : EventArgs<TYPE, T1>, ICommon<T2>
	{
		/// <summary/>
		public T2 Value2;

		T2 ICommon<T2>.Value
		{
			get
			{
				return this.Value2;
			}
			set
			{
				this.Value2 = value;
			}
		}

		HByReturnDelegate<T2, T2> ICommon<T2>.Handler
		{
			get
			{
				return p => this.Value2;
			}
			set
			{
				if (value != null)
					this.Value2 = value(this.Value2);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3> : EventArgs<TYPE, T1, T2>, ICommon<T3>
	{
		/// <summary/>
		public T3 Value3;

		T3 ICommon<T3>.Value
		{
			get
			{
				return this.Value3;
			}
			set
			{
				this.Value3 = value;
			}
		}

		HByReturnDelegate<T3, T3> ICommon<T3>.Handler
		{
			get
			{
				return p => this.Value3;
			}
			set
			{
				if (value != null)
					this.Value3 = value(this.Value3);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3, T4> : EventArgs<TYPE, T1, T2, T3>, ICommon<T4>
	{
		/// <summary/>
		public T4 Value4;

		T4 ICommon<T4>.Value
		{
			get
			{
				return this.Value4;
			}
			set
			{
				this.Value4 = value;
			}
		}

		HByReturnDelegate<T4, T4> ICommon<T4>.Handler
		{
			get
			{
				return p => this.Value4;
			}
			set
			{
				if (value != null)
					this.Value4 = value(this.Value4);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3, T4, T5> : EventArgs<TYPE, T1, T2, T3, T4>, ICommon<T5>
	{
		/// <summary/>
		public T5 Value5;

		T5 ICommon<T5>.Value
		{
			get
			{
				return this.Value5;
			}
			set
			{
				this.Value5 = value;
			}
		}

		HByReturnDelegate<T5, T5> ICommon<T5>.Handler
		{
			get
			{
				return p => this.Value5;
			}
			set
			{
				if (value != null)
					this.Value5 = value(this.Value5);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3, T4, T5, T6> : EventArgs<TYPE, T1, T2, T3, T4, T5>, ICommon<T6>
	{
		/// <summary/>
		public T6 Value6;

		T6 ICommon<T6>.Value
		{
			get
			{
				return this.Value6;
			}
			set
			{
				this.Value6 = value;
			}
		}

		HByReturnDelegate<T6, T6> ICommon<T6>.Handler
		{
			get
			{
				return p => this.Value6;
			}
			set
			{
				if (value != null)
					this.Value6 = value(this.Value6);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3, T4, T5, T6, T7> : EventArgs<TYPE, T1, T2, T3, T4, T5, T6>, ICommon<T7>
	{
		/// <summary/>
		public T7 Value7;

		T7 ICommon<T7>.Value
		{
			get
			{
				return this.Value7;
			}
			set
			{
				this.Value7 = value;
			}
		}

		HByReturnDelegate<T7, T7> ICommon<T7>.Handler
		{
			get
			{
				return p => this.Value7;
			}
			set
			{
				if (value != null)
					this.Value7 = value(this.Value7);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3, T4, T5, T6, T7, T8> : EventArgs<TYPE, T1, T2, T3, T4, T5, T6, T7>, ICommon<T8>
	{
		/// <summary/>
		public T8 Value8;

		T8 ICommon<T8>.Value
		{
			get
			{
				return this.Value8;
			}
			set
			{
				this.Value8 = value;
			}
		}

		HByReturnDelegate<T8, T8> ICommon<T8>.Handler
		{
			get
			{
				return p => this.Value8;
			}
			set
			{
				if (value != null)
					this.Value8 = value(this.Value8);
			}
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class EventArgs<TYPE, T1, T2, T3, T4, T5, T6, T7, T8, T9> : EventArgs<TYPE, T1, T2, T3, T4, T5, T6, T7, T8>, ICommon<T9>
	{
		/// <summary/>
		public T9 Value9;

		T9 ICommon<T9>.Value
		{
			get
			{
				return this.Value9;
			}
			set
			{
				this.Value9 = value;
			}
		}

		HByReturnDelegate<T9, T9> ICommon<T9>.Handler
		{
			get
			{
				return p => this.Value9;
			}
			set
			{
				if (value != null)
					this.Value9 = value(this.Value9);
			}
		}
	}
}
